<?php
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandValidateCredential.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandCreateBill.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandCreateBillDetail.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandCreateNaturalCustomer.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandSelectClientAddressByNaturalCustomerIdNumber.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandSelectPhonesByNaturalCustomerIdNumber.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandSelectExistingNaturalCustomer.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandCreateLegalClient.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandSelectClientAddressByLegalClientRif.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandSelectPhonesByLegalClientRif.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandSelectExistingLegalClient.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandCreatePlace.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandCreateClientAddress.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandSelectProducts.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandSelectProductByCode.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandSelectRequests.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandSelectRequestDetails.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandCreateUser.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandCreateEmployee.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandCreateEmployeeAddress.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandCreateJobHistory.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandCreatePhone.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandCreateNews.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandSelectNews.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandCreateBranch.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandCreateBranchAddress.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandSelectBranches.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . 
		'/SAGER/logic/command/CommandSelectDepartmentsByBranchRif.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandCreateOrder.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandCreateOrderDetail.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandCreateDepartment.php';	
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandSelectEmployees.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandSelectUsers.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandSelectDepartments.php';	
    require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandSelectResources.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandSelectBills.php';	
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandSelectBillDetails.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . 
		'/SAGER/logic/command/CommandCreateResourcesRequest.php';
		require_once $_SERVER['DOCUMENT_ROOT'] . 
		'/SAGER/logic/command/CommandCreateResource.php';
		
    require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandSendEmail.php';	
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandCreateAccount.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandCreateAccountingEntry.php';	
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandCreateBookkeeping.php';		
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandCreatePayExhele.php';	
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandCreatePayInstallation.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandCreatePayPublicity.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandCreateMeasures.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandSelectBillsDuctobarra.php';	
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandSelectBillsDetailsDuctobarra.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/command/CommandSelectBranch.php';
	
	error_reporting (E_ALL ^ E_NOTICE);
	
	$debug = $_SESSION['debug'];
	

	
	/*
	 * Command factory
	 */
	class CommandFactory {
		/**
		 * Creates the command to create measures
		 */
		public static function createCommandCreateMeasures($nameMeasures,$numberMeasures, $measuresDate,$filesMeasures) {			
			return new CommandCreateMeasures($nameMeasures, $numberMeasures, $measuresDate,$filesMeasures);
		}
	/**
		 * Creates the command to create pay installation
		 */
		public static function createCommandCreatePayInstallation($nameInstallation, $amountInstallation, $numberInstallation, $InstallationDate) {			
			return new CommandCreatePayInstallation($nameInstallation, $amountInstallation, $numberInstallation, $InstallationDate);
		}
		/**
		 * Creates the command to create pay publicity
		 */
		public static function createCommandCreatePayPublicity($namePublicity, $amountPublicity, $numberPublicity, 
			$publicityDate) {			
			return new CommandCreatePayPublicity($namePublicity, $amountPublicity, $numberPublicity, 
			$publicityDate);
		}
	/**
		 * Creates the command to create pay exhele
		 */
		public static function createCommandCreatePayExhele($nameExhele, $amountExhele, $numberExhele, 
			$exheleDate) {			
			return new CommandCreatePayExhele($nameExhele, $amountExhele, $numberExhele, 
			$exheleDate);
		}

        /**
		 * Creates the command to create a Department*/
		 
		public static function createCommandCreateDepartment($name, $branch) {
			return new CommandCreateDepartment($name, $branch);
		}
	

		/**
		 * Creates the command to create an order 
		 */
		public static function createCommandCreateOrder($ciRifList, $ciRif, $clientName, 
			$secondName, $firstLastName, $secondLastName, $emailAddress, $startDate, $endDate, 
			$country, $stateProvince, $city, $zone, $homePhone, $mobilePhone, $workPhone, 
			$faxPhone, $orderNumber, $orderControlNumber, $orderDate, $tax,$readStatus, 
			$products,$orderType) {			
			return new CommandCreateOrder($ciRifList, $ciRif, $clientName, $secondName, 
			$firstLastName, $secondLastName, $emailAddress, $startDate, $endDate, $country, 
			$stateProvince, $city, $zone, $homePhone, $mobilePhone, $workPhone, $faxPhone, 
			$orderNumber, $orderControlNumber, $orderDate, $tax,$readStatus, $products,$orderType);
		}
		
		/**
		 * Creates the command to create a Purchase Order detail
		 */
		public static function createCommandCreateOrderDetail($pkLine, $units, $quantity, 
			$unitCost, $pkFkNumberPurchaseOrder, $pkFkControlNumberPurchaseOrder, $pkFkCodeProductInventory, 
			$pkFkRifBranchInventory) {
			return new CommandCreateOrderDetail($pkLine, $units, $quantity, $unitCost, 
				$pkFkNumberOrder, $pkFkControlNumberOrder, $pkFkCodeProductInventory, 
				$pkFkRifBranchInventory);
		}
		

		/*
		* Method to get the command to validate a credential
		*/
		public static function createCommandValidateCredential($username, $password) {
			return new CommandValidateCredential($username, $password);
		}
		/*
		* Method to get the command to Create User
		*/
		
		public static function createCommandCreateUser ($pkUsername,$password,$firstName,$secondName,$firstLastName,$secondLastName,$emailAddress,$fkIdRole) {
			return new CommandCreateUser ($pkUsername,$password,$firstName,$secondName,$firstLastName,$secondLastName,$emailAddress,$fkIdRole);
		}
		/*
		* Method to get the command to Change User
		*/
		
	    public static function createCommandChangeUser ($pkUsername,$password,$firstName,$secondName,$firstLastName,$secondLastName,$emailAddress,$fkIdRole) {
			return new CommandChangeUser ($pkUsername,$password,$firstName,$secondName,$firstLastName,$secondLastName,$emailAddress,$fkIdRole);
		}
		
		/*
		 * Creates the command to create an employee
		 */		
		public static function createCommandCreateEmployee($ci, $firstName, $secondName, 
			$firstLastName, $secondLastName, $emailAddress, $addressStartDate, $addressEndDate, 
			$country, $stateProvince, $city, $zone, $homePhone, $mobilePhone, $workPhone, 
			$faxPhone, $startDate, $endDate, $job, $salary, $branchRif, $departmentId) {
			return new CommandCreateEmployee($ci, $firstName, $secondName, $firstLastName, 
				$secondLastName, $emailAddress, $addressStartDate, $addressEndDate, $country, 
				$stateProvince, $city, $zone, $homePhone, $mobilePhone, $workPhone, $faxPhone, 
				$startDate, $endDate, $job, $salary, $branchRif, $departmentId);
		}
		
		/**
		 * Creates the command to create an employee address
		 */
		public static function createCommandCreateEmployeeAddress($startDate, $endDate, $ci) {
			return new CommandCreateEmployeeAddress($startDate, $endDate, $ci);	
		}
		
		/**
		 * Creates the command to create a job history
		 */
		public static function createCommandCreateJobHistory($startDate, $endDate, $job, $salary, 
			$branchRif, $departmentId) {
			return new CommandCreateJobHistory($startDate, $endDate, $job, $salary, $branchRif, 
				$departmentId);	
		}
		
		/**
		 * Creates the command to select existing branches
		 */
		public static function createCommandSelectBranches() {
			return new CommandSelectBranches();	
		}
				
		/*
		* Method to get the command to 	Change Employee
		*/
		
	   public static function createCommandChangeEmployee ($pkIdNumber, $firstName, $secondName, $firstLastName, 
			$secondLastName, $emailAddress) {
			return new CommandChangeEmployee($pkIdNumber, $firstName, $secondName, $firstLastName, 
			$secondLastName, $emailAddress);
		}		
	   
		
		/**
		 * Creates the command to select existing departments by branch rif
		 */
		public static function createCommandSelectDepartmentsByBranchRif($rif) {
			return new CommandSelectDepartmentsByBranchRif($rif);
		}
		
		/*
		* Method to get the command to Create Supplier
		*/
		
		public static function createCommandCreateSupplier ($pkRif,$name) {
			return new CommandCreateSupplier ($pkRif,$name) ;
		}
		/*
		* Method to get the command to Change Supplier
		*/
		
		public static function createCommandChangeSupplier ($pkRif,$name) {
			return new CommandChangeSupplier ($pkRif,$name) ;
		}
		/*
		* Method to get the command to Create Branch
		*/
	
		public static function createCommandCreateBranch ($pkRif,$name,$country, $stateProvince, $city, $zone, $startDate, $endDate){
			return new CommandCreateBranch ($pkRif,$name,$country, $stateProvince, $city, $zone, $startDate, $endDate) ;
		}	
		
		/*
		* Method to get the command to BranchAddress
		*/
		public static function createCommandCreateBranchAddress ($pkStartDate, $endDate, $pkFkRifBranch){
			return new CommandCreateBranchAddress($pkStartDate, $endDate, $pkFkRifBranch) ;
		}
		
		/*
		* Method to get the command to Change 	Branch
		*/
		public static function createCommandChangeBranch ($pkRif,$name) {
			return new CommandChangeBranch($pkRif,$name) ;
		}
		
		/**
		 * Creates the command to create a bill
		 */
		public static function createCommandCreateBill($ciRifList, $ciRif, $clientName, 
			$secondName, $firstLastName, $secondLastName, $emailAddress, $startDate, $endDate, 
			$country, $stateProvince, $city, $zone, $homePhone, $mobilePhone, $workPhone, 
			$faxPhone, $billNumber, $billControlNumber, $billDate, $tax, $products) {			
			return new CommandCreateBill($ciRifList, $ciRif, $clientName, $secondName, 
				$firstLastName, $secondLastName, $emailAddress, $startDate, $endDate, $country, 
				$stateProvince, $city, $zone, $homePhone, $mobilePhone, $workPhone, $faxPhone, 
				$billNumber, $billControlNumber, $billDate, $tax, $products);
		}
		
		/**
		 * Creates the command to create a bill detail
		 */
		public static function createCommandCreateBillDetail($pkLine, $units, $quantity, 
			$unitCost, $pkFkNumberBill, $pkFkControlNumberBill, $pkFkCodeProductInventory, 
			$pkFkRifBranchInventory) {
			return new CommandCreateBillDetail($pkLine, $units, $quantity, $unitCost, 
				$pkFkNumberBill, $pkFkControlNumberBill, $pkFkCodeProductInventory, 
				$pkFkRifBranchInventory);
		}
		
		/**
		 * Creates the command to create a natural customer
		 */
		public static function createCommandCreateNaturalCustomer($pkIdNumber, $firstName, 
			$secondName, $firstLastName, $secondLastName, $emailAddress) {
			return new CommandCreateNaturalCustomer($pkIdNumber, $firstName, $secondName, 
				$firstLastName, $secondLastName, $emailAddress);
		}
		
		/**
		 * Creates the command to select a client address by natural customer id number
		 */
		public static function createCommandSelectClientAddressByNaturalCustomerIdNumber($ci) {
			return new CommandSelectClientAddressByNaturalCustomerIdNumber($ci);
		}
		
		/**
		 * Creates the command to select phones by natural customer id number
		 */
		public static function createCommandSelectPhonesByNaturalCustomerIdNumber($ci) {
			return new CommandSelectPhonesByNaturalCustomerIdNumber($ci);
		}
		
		/**
		 * Creates the command to select an existing natural customer
		 */
		public static function createCommandSelectExistingNaturalCustomer($ci) {
			return new CommandSelectExistingNaturalCustomer($ci);	
		}
		
		/**
		 * Creates the command to create a legal client
		 */
		public static function createCommandCreateLegalClient($pkRif, $name, $emailAddress) {
			return new CommandCreateLegalClient($pkRif, $name, $emailAddress);
		}
		
		/**
		 * Creates the command to select a client address by legal client rif
		 */
		public static function createCommandSelectClientAddressByLegalClientRif($rif) {
			return new CommandSelectClientAddressByLegalClientRif($rif);
		}
		
		/**
		 * Creates the command to select phones by legal client rif
		 */
		public static function createCommandSelectPhonesByLegalClientRif($rif) {
			return new CommandSelectPhonesByLegalClientRif($rif);
		}
		
		/**
		 * Creates the command to select an existing legal client
		 */
		public static function createCommandSelectExistingLegalClient($rif) {
			return new CommandSelectExistingLegalClient($rif);	
		}
		
		/**
		 * Creates the command to create a place
		 */
		public static function createCommandCreatePlace($place) {
			return new CommandCreatePlace($place);	
		}
		
		/**
		 * Creates the command to create a client address
		 */
		public static function createCommandCreateClientAddress($clientAddress) {
			return new CommandCreateClientAddress($clientAddress);	
		}
		
		/**
		 * Creates the command to create a phone
		 */
		public static function createCommandCreatePhone($phone) {
			return new CommandCreatePhone($phone);
		}
		
		/**
		 * Creates the command to select all existing products
		 */
		public static function createCommandSelectProducts() {
			return new CommandSelectProducts();	
		}
		
		/**
		 * Creates the command to select a single product by code
		 */
		public static function createCommandSelectProductByCode($pkCode) {
			return new CommandSelectProductByCode($pkCode);	
		}
		
		/**
		 * Creates the command to select all existing requests
		 */
		public static function createCommandSelectRequests($order) {
			return new CommandSelectRequests($order);	
		}
		
		/**
		 * Creates the command to select given request details
		 */
		public static function createCommandSelectRequestDetails($number, $controlNumber) {
			return new CommandSelectRequestDetails($number, $controlNumber);	
		}
		
		/**
		 * Creates the command to create a resources request
		 */
		public static function createCommandCreateResourcesRequest($date, $readStatus, 
			$requester) {
			return new CommandCreateResourcesRequest($date, $readStatus, $requester);
		}
		
		/**
		 * Creates the command to create a resource
		 */
		public static function createCommandCreateResource($category, $identifier, 
			$specifications, $cost) {
			return new CommandCreateResource($category, $identifier, $specifications, $cost);
		}
		
		public static function createCommandChangeBill ($pkNumber, $pkControlNumber, $date, $tax, 
			$fkIdNumberNaturalCustomer, $fkRifLegalClient) {
			return new CommandChangeBill ($pkNumber, $pkControlNumber, $date, $tax, 
			$fkIdNumberNaturalCustomer, $fkRifLegalClient) ;
		}
	
		/*

		* Method to get the command to Change Purchase Order
		*/	
		public static function createCommandChangePurchaseOrder ($pkNumber, $pkControlNumber, $date, $tax, $readStatus,$fkIdNumberNaturalCustomer, $fkRifLegalClient) {
			return new CommandChangePurchaseOrder ($pkNumber, $pkControlNumber, $date, $tax, $readStatus,$fkIdNumberNaturalCustomer, $fkRifLegalClient) ;
		}
		/*

		* Method to get the command to Create Product
		*/
	   public static function createCommandCreateProduct ($pkCode, $name, $unitCost){
			return new CommandCreateProduct ($pkCode, $name, $unitCost) ;
		}	
		/*
		* Method to get the command to Change Product
		*/
	   public static function createCommandChangeProduct ($pkCode, $name, $unitCost){
			return new CommandChangeProduct ($pkCode, $name, $unitCost) ;
		}	
	
		
		/*
		* Method to get the command to Change Account
		*/
	  public static function createCommandChangeAccount ($pk_number, $type, $name, $description) {
			return new CommandChangeAccount ($pk_number, $type, $name, $description)  ;
		}	
		/*
		* Method to get the command to CreateNews
		*/
	  public static function createCommandCreateNews ($date, $image, $title, $description) {
			return new CommandCreateNews ($date, $image, $title, $description)  ;
			
		}		
		
		/**
		 * Creates the command to select all existing news
		 */
		public static function createCommandSelectNews() {
			return new CommandSelectNews();	
		}
		
	 	/**
		 * Creates the command to select all existing employees
		 		 */
		public static function createCommandSelectEmployees() {
			return new CommandSelectEmployees();	
		}	
		
			 	/**
		 * Creates the command to select all existing users
		 */
		public static function createCommandSelectUsers() {
			return new CommandSelectUsers();	
		}			
		
					 	/**
		 * Creates the command to select all existing departments
		 */
		public static function createCommandSelectDepartments() {
			return new CommandSelectDepartments();	
		}
		
					 	/**
		 * Creates the command to select all existing resources
		 */
		public static function createCommandSelectResources() {
			return new CommandSelectResources();	
		}
							 	/**
		 * Creates the command to select all existing bills
		 */
		public static function createCommandSelectBills() {
			return new CommandSelectBills();	
		}
					
			/**
		 * Creates the command to select given bill details
		 */
		public static function createCommandSelectBillDetails($number, $controlNumber) {
			return new CommandSelectBillDetails($number, $controlNumber);	
		}
		
			/**
		 * Creates the command to send email
		 */
		public static function createCommandSendEmail($email) {
			return new CommandSendEmail($email);	
		}
		
			
		/**
		 * Creates the command Account
		 */
		public static function createCommandCreateAccount($name, 
				$description, $mount, $type) {
			return new CommandCreateAccount($name, 
				$description, $mount, $type);	
		}
		
		/**
		 * Creates the command AccountEntry
		 */
		public static function createCommandCreateAccountingEntry($date) {
			$GLOBALS['debug']->log($date,"Objeto account");	
			return new CommandCreateAccountingEntry($date);	
		}
		
		/**
		 * Creates the command Bookkeeping
		 */
		public static function createCommandCreateBookeeping($debit,$havings,$pkNumberAccountingEntry,$pkNumberAccount,$fkLineBillDetail,$fkNumberBillDetail,$fkControlNumber,$fkcodeproduct,$fkRifBranch,$fkIdPurchase,$suplierPurchase,$fkCodeProductPurchase,$fkBranchInventory){
			return new CommandCreateBookkeeping($debit,$havings,$pkNumberAccountingEntry,$pkNumberAccount,$fkLineBillDetail,$fkNumberBillDetail,$fkControlNumber,$fkcodeproduct,$fkRifBranch,$fkIdPurchase,$suplierPurchase,$fkCodeProductPurchase,$fkBranchInventory);	
		}
		
							 	/**
		 * Creates the command to select all existing bills ductobarra
		 */
		public static function createCommandSelectBillsDuctobarra() {
			return new CommandSelectBillsDuctobarra();	
		}
					
			/**
		 * Creates the command to select given bill details ductobarra
		 */
		public static function createCommandSelectBillsDetailsDuctobarra($number, $controlNumber) {
			return new CommandSelectBillsDetailsDuctobarra($number, $controlNumber);	
		}
	
			/**
		 * Creates the command to select all existing branch
		 */
		public static function createCommandSelectBranch() {
			return new CommandSelectBranch();	
		}
	

				
	}
?>